package com.windowes.weichang.service;

import com.windowes.weichang.common.ServerResponse;
import com.windowes.weichang.dao.DemandProducingStepMapper;
import com.windowes.weichang.pojo.DemandProducingStep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/8/5 下午12:29
 * @description:
 *
 **/
@Service
public class DemandProducingStepService {

    @Autowired
    DemandProducingStepMapper producingStepMapper;

    public ServerResponse list() {
        List<DemandProducingStep> list = producingStepMapper.selectAll();
        return ServerResponse.createBySuccess(list);
    }

    public ServerResponse addOrUpdate(DemandProducingStep step) {
        if (step.getId() == null) {
            producingStepMapper.insertSelective(step);
        } else {
            producingStepMapper.updateByPrimaryKeySelective(step);
        }
        return ServerResponse.createBySuccessMessage("操作成功!");
    }
}
